<template>
  <img alt="Vue logo" src="./assets/logo.png">
  <!-- 传统写法 -->
  <p @click="$store.commit('add')">{{$store.state.count}}</p>
  <!-- composition写法 -->
  <p @click="add">{{count}}</p>
  <HelloWorld msg="Welcome to Your Vue.js App"/>
</template>

<script>
import { toRefs } from 'vue'
import { useStore } from 'vuex'
import HelloWorld from './components/HelloWorld.vue'

export default {
  name: 'App',
  components: {
    HelloWorld
  },
  setup() {
    const store = useStore()
    console.log(store)
    return{
      //state: store.state,
      ...toRefs(store.state),
      add() {
        store.commit('add')
      }
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
